package com.zcf.gameController.gameUtils;

import com.zcf.pojo.RoomsParam;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Random;

/**
 * @author jj
 * @date 2019/11/13 21:19
 */
public class Algorithm {
    /**
     * 发牌 0 推筒子 1 三公
     * @param room
     * @param type
     */
  public static void deal(RoomsParam room,int type){
      List<Integer> roomCards = new ArrayList<>(room.getRoomCards());
      Map<Integer, List<Integer>> cards = room.getCards();
      int size = room.getPostions().size();
      int frame=0;
      if (type==0){
          frame=2;
      }else {
          frame=3;
      }
      for (int i=0;i < size; i++){
          List<Integer> card=new ArrayList<>();;
          for (int j=0;j<frame;j++){
              Random rand = new Random();
              int random=rand.nextInt(roomCards.size());
              Integer integer = roomCards.get(random);
              card.add(integer);
              roomCards.remove(random);
          }
          cards.put(i,card);
      }
  }


}
